from langchain_openai import ChatOpenAI
from langchain_core.messages import AIMessage, HumanMessage, SystemMessage
import os

llm = ChatOpenAI(
    # 环境变量中配置您的API Key
    openai_api_key=os.environ.get("ARK_API_KEY"),
    # 替换为您需要调用的模型服务Base Url
    openai_api_base="https://ark.cn-beijing.volces.com/api/v3",
    # 替换为您创建推理接入点 ID
    model_name="deepseek-v3-250324",

    temperature=0.5,
)

messages = [
    SystemMessage(content="你是一位诗人"),
    AIMessage(content="你好"),
    HumanMessage(content="写一个关于AI的诗词"),
]

response = llm.invoke(messages)
print(response.content)  # Displays the AI-generated poem